package com.sunny.wordstudy;

import android.app.Activity;
import android.app.AlertDialog.Builder;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import com.sunny.wordstudy.lib.Stat;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ChooseDBView extends Activity
{
  Stat a = Stat.a();
  ProgressDialog b = null;
  String c = null;
  SharedPreferences d;
  ListView e;
  String f = "/sdcard/wordstudy/";
  List g;
  final int h = 0;
  final int i = 1;
  AdapterView.OnItemClickListener j = new a(this);

  private void b()
  {
    TextView localTextView = (TextView)findViewById(2131230720);
    localTextView.setSingleLine(true);
    StringBuilder localStringBuilder1 = new StringBuilder(String.valueOf(this.a.getStudyBookName())).append(" ");
    Resources localResources1 = getResources();
    Object[] arrayOfObject1 = new Object[2];
    arrayOfObject1[0] = Long.valueOf(this.a.getTotalIntroducedWords());
    arrayOfObject1[1] = Long.valueOf(this.a.getBookWords());
    StringBuilder localStringBuilder2 = new StringBuilder(String.valueOf(localResources1.getString(2131099763, arrayOfObject1))).append(" ");
    Resources localResources2 = getResources();
    Object[] arrayOfObject2 = new Object[2];
    arrayOfObject2[0] = Long.valueOf(this.a.getTotalLearnedTime() / 60L);
    arrayOfObject2[1] = Long.valueOf(this.a.getTotalLearnedTime() % 60L);
    localTextView.setText(localResources2.getString(2131099762, arrayOfObject2));
  }

  public final void a()
  {
    AlertDialog.Builder localBuilder = new AlertDialog.Builder(this);
    localBuilder.setIcon(getResources().getDrawable(2130837511));
    localBuilder.setTitle(getResources().getString(2131099846));
    localBuilder.setMessage(getResources().getString(2131099847));
    localBuilder.setPositiveButton(getResources().getString(2131099786), new d(this));
    localBuilder.setNegativeButton(getResources().getString(2131099787), new e(this));
    localBuilder.show();
  }

  final void a(String paramString)
  {
    this.g = new ArrayList();
    File localFile1 = new File(paramString);
    if (!(localFile1.exists()))
      localFile1.mkdirs();
    File[] arrayOfFile;
    int k;
    if (localFile1.isDirectory())
    {
      arrayOfFile = localFile1.listFiles();
      new String();
      if (!(paramString.equals(this.f)))
      {
        HashMap localHashMap1 = new HashMap();
        localHashMap1.put("item", getResources().getString(2131099790) + "/");
        localHashMap1.put("desc", new String("Directory <<"));
        localHashMap1.put("file", this.f);
        localHashMap1.put("pic", Integer.valueOf(2130837505));
        this.g.add(localHashMap1);
        HashMap localHashMap2 = new HashMap();
        localHashMap2.put("item", getResources().getString(2131099790) + "/");
        localHashMap2.put("desc", new String("Directory <<"));
        localHashMap2.put("file", localFile1.getParent());
        localHashMap2.put("pic", Integer.valueOf(2130837504));
        this.g.add(localHashMap2);
      }
      k = 0;
      label279: if (k < arrayOfFile.length)
        break label467;
      if (paramString.equals(this.f))
      {
        HashMap localHashMap5 = new HashMap();
        localHashMap5.put("item", getResources().getString(2131099843));
        localHashMap5.put("desc", getResources().getString(2131099844));
        localHashMap5.put("file", "");
        localHashMap5.put("pic", Integer.valueOf(2130837509));
        this.g.add(localHashMap5);
      }
    }
    String[] arrayOfString = new String[3];
    arrayOfString[0] = "pic";
    arrayOfString[1] = "item";
    arrayOfString[2] = "desc";
    int[] arrayOfInt = new int[3];
    arrayOfInt[0] = 2131230741;
    arrayOfInt[1] = 2131230742;
    arrayOfInt[2] = 2131230743;
    SimpleAdapter localSimpleAdapter = new SimpleAdapter(this, this.g, 2130903046, arrayOfString, arrayOfInt);
    this.e.setAdapter(localSimpleAdapter);
    this.e.setOnItemClickListener(this.j);
    return;
    label467: File localFile2 = arrayOfFile[k];
    if (localFile2.getName().startsWith("usr_"))
    {
      if (!(localFile2.isDirectory()))
        break label593;
      HashMap localHashMap3 = new HashMap();
      localHashMap3.put("item", localFile2.getName().substring(4));
      localHashMap3.put("desc", new String("Directory >>"));
      localHashMap3.put("file", localFile2.getPath());
      localHashMap3.put("pic", Integer.valueOf(2130837508));
      this.g.add(localHashMap3);
    }
    while (true)
    {
      ++k;
      break label279:
      label593: if ((!(localFile2.isFile())) || (!(localFile2.getName().endsWith(".edb"))))
        continue;
      String str = this.a.getDBSummary(localFile2.getPath());
      if (str.equals("0"))
        continue;
      HashMap localHashMap4 = new HashMap();
      localHashMap4.put("item", localFile2.getName().substring(4) + " " + String.valueOf(localFile2.length() / 1024L) + "KB");
      localHashMap4.put("desc", str);
      localHashMap4.put("file", localFile2.getPath());
      localHashMap4.put("pic", Integer.valueOf(2130837507));
      this.g.add(localHashMap4);
    }
  }

  protected void onActivityResult(int paramInt1, int paramInt2, Intent paramIntent)
  {
    a(this.f);
  }

  public void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setContentView(2130903040);
    this.d = PreferenceManager.getDefaultSharedPreferences(this);
    setTitle(getResources().getString(2131099759));
    this.e = ((ListView)findViewById(2131230721));
    a(this.f);
    b();
  }

  public boolean onCreateOptionsMenu(Menu paramMenu)
  {
    super.onCreateOptionsMenu(paramMenu);
    paramMenu.add(0, 0, 0, getResources().getString(2131099841));
    paramMenu.add(0, 1, 1, getResources().getString(2131099842));
    return true;
  }

  public boolean onOptionsItemSelected(MenuItem paramMenuItem)
  {
    switch (paramMenuItem.getItemId())
    {
    default:
    case 0:
    case 1:
    }
    while (true)
    {
      return true;
      a();
      continue;
      finish();
    }
  }
}

/* Location:           E:\Desktop\Android\wordstd\classes_dex2jar.jar
 * Qualified Name:     com.sunny.wordstudy.ChooseDBView
 * JD-Core Version:    0.5.3
 */